package com.zhongfl.crm.model.boss;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author wang.yuchuan
 * @date 2018/4/19
 */
@Component
public class RedisKeyUtils {
    @Value("${app.key}")
    private String appKey;

    public static final String COLON = ":";

    /**
     * 默认过期时间, 一小时
     */
    public static final long DEFAULT_EXPIRATION = 3600;

    /**
     * 生成redisKey
     *
     * @param args
     * @return
     */
    public String generateKey(String... args) {
        StringBuilder sb = new StringBuilder();
        sb.append(appKey);
        if (args.length > 0) {
            for (String arg : args) {
                sb.append(COLON).append(arg);
            }
        } else {
            sb.append(COLON).append("EMPTY");
        }
        return sb.toString();
    }
}
